/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package nl.maxato.modellen;

import java.util.List;
import javax.swing.table.AbstractTableModel;

import nl.maxato.domain.Wage;

/**
 *
 * @author Danny
 */
public class WageTableModel extends AbstractTableModel {

    private List<Wage> wages;
    String[] columnNames;
    //private Atleet atleet;
    //private List<Usertabel> following;

    public WageTableModel(List<Wage> wages) {
        this.wages = wages;
        //this.atleet = atleet;
        //following = user.getUsertabelCollection();
        //System.out.println("Following: " + atleet.getUsertabelCollection());
    }

    public void setColumnNames(String name, String age, String maxid, String fans, String foreigner, String oldSal, String newSal, String differences) {
        String[] columnNamesNieuw = {name, age, maxid, fans, foreigner, oldSal, newSal, differences};
        this.columnNames = columnNamesNieuw;
    }

    @Override
    public int getColumnCount() {
        return 8;
    }

    @Override
    public String getColumnName(int col) {
        return columnNames[col];
    }

    @Override
    public int getRowCount() {
        return wages.size();
    }

    @Override
    public Object getValueAt(int row, int col) {
        switch (col) {
            case 0:
                return wages.get(row).getAthletes().getName() + " " + wages.get(row).getAthletes().getSurname();
            case 1:
                return wages.get(row).getAthletes().getAge();
            case 2:
                return wages.get(row).getAthletes().getMaxid();
            case 3:
                return wages.get(row).getAthletes().getFans();
            case 4:
                return wages.get(row).getForeigner();
            case 5:
                return wages.get(row).getAthletes().getWage();
            case 6:
                return wages.get(row).getNewSal();
            case 7:
                return wages.get(row).getNewSal() - wages.get(row).getAthletes().getWage();
            default:
                throw new RuntimeException("no such column");
        }
    }

    // This method is used by the JTable to define the default
    // renderer or editor for each cell. For example if you have
    // a boolean data it will be rendered as a check box. A
    // number value is right aligned.
    @Override
    public Class<?> getColumnClass(int columnIndex) {
        switch (columnIndex) {
            case 0:
                return wages.get(columnIndex).getAthletes().getName().getClass();
            case 1:
                return Integer.class;
            case 2:
                return Integer.class;
            case 3:
                return Integer.class;
            case 4:
                return wages.get(columnIndex).getForeigner().getClass();
            case 5:
                return Integer.class;
            case 6:
                return Integer.class;
            case 7:
                return Integer.class;
            default:
                throw new RuntimeException("no such column");
        }
    }
}
